package com.example.orderservice.controller;

import com.example.baseserver.util.Reply;
import com.example.orderservice.pojo.vo.DiscountUserAndDiscountsVO;
import com.example.orderservice.service.DiscountUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 鱼凫
 * @version 1.0
 * Create by 2023/4/12 10:46
 */
@Api(tags="折扣-用户相关接口")
@RestController
@RequestMapping("api/discountsUser")
public class DiscountUserController {

    @Autowired
    DiscountUserService discountUserService;

    @ApiOperation("拿到我的优惠券列表")
    @PostMapping("my")
    public Reply<List<DiscountUserAndDiscountsVO>> getListByUid() {
        return Reply.success(discountUserService.getMyDiscount());
    }

    @ApiOperation("领取优惠券")
    @PostMapping("gotCoupon")
    public Reply gotCoupon(String discountsId) {
        discountUserService.gotCoupon(discountsId);
        return Reply.success("领取成功!");
    }
}
